#include "App_Display.h"

void App_Display_Init(void) {
    Inf_OLED_Init();

    App_Display_ShowPIN();
}

// 显示一些固定的字符
void App_Display_ShowPIN(void) {
    oled_draw_string(5, 0, "VOL:");
    oled_draw_string(5, 2, "CUR:");
    oled_draw_string(5, 4, "POW:");
    oled_draw_string(5, 6, "ELE:");

    oled_draw_char(100, 0, 'V');
    oled_draw_char(100, 2, 'A');
    oled_draw_char(100, 4, 'W');
    oled_draw_string(100, 6, "WH");
}

// 显示电压、电流、功率、用电量
void App_Display_Show(void) {
    char a[4][8] = {0};
    sprintf(a[0], "%07.3f", power_values.voltage);
    sprintf(a[1], "%07.3f", power_values.current);
    sprintf(a[2], "%07.3f", power_values.active_power);
    sprintf(a[3], "%07.3f", power_values.electricity);

    oled_draw_string(40, 0, a[0]);
    oled_draw_string(40, 2, a[1]);
    oled_draw_string(40, 4, a[2]);
    oled_draw_string(40, 6, a[3]);
}
